// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1

    Item {
        property string langID
        id:main
        width:250; height:110
        signal openFullWeather()
        MouseArea{
            x:0;y:0;width:parent.width;height:parent.height
            onClicked:{console.log("Weather Widget Clicked");openFullWeather();}
        }

        XmlListModel {
            id: xmlCurrentWeather
            source: "data/weatherExample.xml"
    //source: "http://api.wunderground.com/api/44cf3daadaaf3596/conditions/forecast/hourly/q/autoip.xml"
            query: "/response/current_observation"
            XmlRole { name: "cityName"; query: "display_location/full/string()" }
            XmlRole { name: "weatherDescription"; query: "weather/string()" }
            XmlRole { name: "temp_f"; query: "temp_f/number()" }
            XmlRole { name: "temp_c"; query: "temp_c/number()" }
            XmlRole { name: "relative_humidity"; query: "relative_humidity/string()" }
            XmlRole { name: "wind_dir"; query: "wind_dir/string()" }
            XmlRole { name: "wind_mph"; query: "wind_mph/string()" }
            XmlRole { name: "pressure_mb"; query: "pressure_mb/string()" }
            XmlRole { name: "pressure_trend"; query: "pressure_trend/string()" }
            XmlRole { name: "dewpoint_f"; query: "dewpoint_f/string()" }
            XmlRole { name: "dewpoint_c"; query: "dewpoint_c/string()" }
            XmlRole { name: "icon"; query: "icon/string()" }
        }
        XmlListModel {
            id: xmlNextDay
            source: "data/weatherExample.xml"
        //source: "http://api.wunderground.com/api/44cf3daadaaf3596/conditions/forecast/hourly/q/autoip.xml"
            query: "/response/forecast/simpleforecast/forecastdays/forecastday[position() < 4]"
            XmlRole { name: "weekDay"; query: "date/weekday/string()" }
            XmlRole { name: "weatherDescription"; query: "conditions/string()" }
            XmlRole { name: "temp_high_f"; query: "high/fahrenheit/number()" }
            XmlRole { name: "temp_high_c"; query: "high/celsius/number()" }
            XmlRole { name: "temp_low_f"; query: "low/fahrenheit/number()" }
            XmlRole { name: "temp_low_c"; query: "low/celsius/number()" }
            XmlRole { name: "average_humidity"; query: "avehumidity/string()" }
            XmlRole { name: "wind_dir"; query: "avewind/dir/string()" }
            XmlRole { name: "wind_mph"; query: "avewind/mph/number()" }
            XmlRole { name: "icon"; query: "icon/string()" }
            XmlRole { name: "skyicon"; query: "skyicon/string()" }
        }



        ListView {
            x: 0
            y: 0
             width: 250; height: 40
             interactive: false
             model: xmlCurrentWeather
             delegate: xmlCurrentWeatherDelegate
         }
        Component{
            id: xmlCurrentWeatherDelegate

            Rectangle {
                MouseArea {
                    id: mousearea1
                    x: 0
                    y: 0
                    anchors.rightMargin: 0
                    anchors.bottomMargin: 0
                    anchors.leftMargin: 0
                    anchors.topMargin: 0
                    anchors.fill: parent
                    onClicked: {
                        xmlCurrentWeather.reload()
                    }


                }

                width: 250
                height: 40
                 color: "#00000000"

                 Image {
                     id: image1
                     x: 125
                     y: -10
                     width: 128
                     height: 128
                     source: "Assets/weather_icons/mostlysunny.png"
                 }

                 Text {
                     id: text1
                     x: 10
                     y: 5
                     text: temp_f+ " °F"
                     font.family: "Georgia"
                     font.bold: true
                     font.pixelSize: 24
                 }

                 Text {
                     id: text2
                     x: 0
                     y: 35
                     text: weatherDescription
                     font.family: "Georgia"
                     font.pixelSize: 12
                 }

                 Text {
                     id: text3
                     x: 0
                     y: 55
                     text: if(langID == "1") "Wind: " +wind_dir+" at " + wind_mph+" mph";
                            else "Viento: " +wind_dir+" at " + wind_mph+" mph";
                     font.family: "Georgia"
                     font.pixelSize: 12
                 }

                 Text {
                     id: text4
                     x: 0
                     y: 75
                     text: if(langID == "1")"Humidity: "+ relative_humidity; else "Humidades: "+ relative_humidity
                     font.family: "Georgia"
                     font.pixelSize: 12
                 }

            }
        }

    }






    //Michal
//Westin but resized from michal's code.
